package com.dxf.bigdata.D05_spark_again.action

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *  初始值,分区内和分区间规则一样
 */
object fold {

  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("app")
    sparkConf.set("spark.port.maxRetries","100")
    val sc = new SparkContext(sparkConf)

    val value: RDD[Int] = sc.makeRDD(List(4, 2, 3, 1),2)

    //    fold zeroValue 会参与分区内计算和分区间计算
    val i: Int = value.fold(10)(_ + _)

    println(i) // 40

    sc.stop()

  }

}
